// stores/workOrder.ts
import { defineStore } from 'pinia';
// import { WorkOrder } from '@/types/workOrder';

export const useWorkOrderStore = defineStore('workOrder', {
  state: () => ({
    orders: [
      {
        id: '3892343242',
        title: 'A207电器无法投屏',
        createTime: '2024/1/12 11:12:13',
        assigner: '张老师',
        status: 'unprocessed',
        alarm: 'A207电器无法投屏',
        handler: '李师傅',
        dispatchTime: '2024/1/12 11:12:13'
      },
      // 添加更多模拟数据...
    ] as any[]
  }),

  getters: {
    unprocessedCount: (state) => state.orders.filter(o => o.status === 'unprocessed').length,
    processedCount: (state) => state.orders.filter(o => o.status === 'processed').length
  },

  actions: {
    updateOrder(updatedOrder: any) {
      const index = this.orders.findIndex(o => o.id === updatedOrder.id);
      if (index !== -1) {
        this.orders[index] = updatedOrder;
      }
    }
  }
});